//
//  WMAuthenticationManager.h
//  WonderBaseSDK_Example
//
//  Created by zero on 2020/5/12.
//  Copyright © 2020 wenhaoChan. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

/// 认证回调
/// @param isAuth 是否完成了认证 isAuth： YES 认证成功 NO 认证失败
typedef void(^WMAuthManagerCompletionHandler)(BOOL isAuth);

typedef void(^WMProtocolConfirmBlock)(void);

typedef void(^ShowViewBlock)(void);

typedef void(^CloseViewBlock)(void);

typedef void(^MessageBlock)(NSDictionary *dicMsg);


@interface WMAuthenticationManager : NSObject

/// 是否为审核版本，默认不是
@property (nonatomic, assign) BOOL isAuditVersion;

/// 是否需要开启实名认证，默认不开启
@property (nonatomic, readonly, assign) BOOL needAuth;


/// 是否需要开启同意隐私协议，默认不开启
@property (nonatomic, assign) BOOL checkPri;

/// 当前用户是否已成年
@property (nonatomic, readonly, assign) BOOL isAdult;

/// 当前用户是否已认证
@property (nonatomic, readonly, assign) BOOL isAuthenticated;

/// 今天是否节假日
@property (nonatomic, readonly, assign) BOOL isHoliday;

/// 节假日数组
@property (nonatomic, readonly, copy) NSArray* holidays;

/// 游戏开始时间
@property (nonatomic, readonly, assign) NSTimeInterval currentTime;

/// 当前认证用户身份证号
@property (nonatomic, readonly, copy) NSString* currentUserIdcard;

/// 当前认证用户年龄
@property (nonatomic, readonly, assign) NSUInteger currentUserAge;

@property (nonatomic, readonly, copy) NSString* protocolUrl;

@property (nonatomic, readonly, copy) NSString* privacyUrl;

@property (nonatomic, assign) BOOL autoInitNotification;

/// launchOptions
@property (nonatomic, copy) NSDictionary *tmpLaunchOptions;


/// 认证回调
@property (nonatomic, copy) WMAuthManagerCompletionHandler authBlock;

@property (nonatomic, copy) WMProtocolConfirmBlock protocolConfirmBlock;

// 隐私条款页面显示回调
@property (nonatomic, copy) ShowViewBlock showProtocolViewBlock;

// 隐私条款页面关闭回调
@property (nonatomic, copy) CloseViewBlock closeProtocolViewBlock;

// 实名认证提示页面显示回调
@property (nonatomic, copy) ShowViewBlock showProtocolTipViewBlock;

// 实名认证提示页面关闭回调
@property (nonatomic, copy) CloseViewBlock closeProtocolTipViewBlock;

// 认证页面显示回调
@property (nonatomic, copy) ShowViewBlock showAuthViewBlock;

// 认证页面关闭回调
@property (nonatomic, copy) CloseViewBlock closeAuthViewBlock;

// 未成年人提示页面显示回调
@property (nonatomic, copy) ShowViewBlock showAuthTipViewBlock;

// 未成年人提示页面关闭回调
@property (nonatomic, copy) CloseViewBlock closeAuthTipViewBlock;

// 退出页面显示回调
@property (nonatomic, copy) ShowViewBlock showTipViewBlock;

// 退出页面关闭回调
@property (nonatomic, copy) CloseViewBlock closeTipViewBlock;

// 收到消息的回调
@property (nonatomic, copy) MessageBlock msgBlock;

+ (instancetype)manager;


//- (void)setupWithAppKey:(NSString *)appKey;

- (void)setupWithAppName:(NSString *)appName Channel:(NSString *)channel;


/// 获取BMS配置
/// @param bmsAppName BMS唯一标识
/// @param version 版本号
- (void)setupBmsConfigWithBmsAppName:(NSString *)bmsAppName Version:(NSString *)version;

//IP判断是否是大陆
+ (void)ipAreaWithVersion:(NSString *)version completionHandler:(void (^)(BOOL isSuccess, BOOL isChina))completionHandler;

/// 设置友盟 sdk
/// @param appKey appkey
/// @param channel 渠道
+ (void)setupUmWithAppKey:(NSString *)appKey channel:(NSString *)channel;

+ (void)setupUm;

//获取bms配置
+ (void)getLaunchConfigWithVersion:(NSString *)version completionHandler:(void (^)(BOOL isSuccess, NSString* language, NSString* message))completionHandler;

/// 是否已同意隐私协议
+ (BOOL)isConfirmProtocol;

/// 是否认证
+ (BOOL)isAuthenticated;

/// 是否成年
+ (BOOL)isAdult;

/// 当前用户年龄
+ (int)currentUserAge;

- (void)addictionPreventionAlert:(NSUInteger)type time:(NSUInteger)time;


/// 充值
/// @param money 金额
+ (void)purchase:(CGFloat)money;

/// 判断当前年龄和金额是否可以充值
/// @param money 充值金额
+ (BOOL)canUserPurchase:(CGFloat)money;


/// 开始认证流程
- (void)startAuth;

/// 隐私政策弹窗
/// @param confirmBlock 已同意回调
//- (void)showProtocolAlertInView:(UIView * _Nullable)view
//                     completion:(nullable void (^)(void))confirmBlock;

/// 实名认证请求
/// @param theId 身份证号码
/// @param name 姓名
- (void)authenticated:(NSString *)theId name:(NSString *)name;


/// 开启初始化应用通知，需要在同意隐私条款后再调用
- (void)setupNotification;

/// SDK内部远程消息处理
/// @param application application
/// @param userInfo userInfo
/// @param completionHandler completionHandler
- (void)wm_application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler;

/// DEBUG 调试方法

//- (void)enterTheGame;
//
//- (void)configServerTime:(NSDate *)date;
//
//- (void)modifyGameTime:(NSUInteger)time;

-(void)authenticationViewCompletionHandlerName:(NSString *)idnum name:(NSString *)name authType: (NSUInteger) authType;

-(void)WMProtocolTipViewAgain;

-(void)networkTipViewDiss;

@end

NS_ASSUME_NONNULL_END
